home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / graphics / bigcolor.lzh / BIGCOLOR.S < prev   
Text File  |  1990-02-06  |  45KB  |  2,046 lines

  1. ;                    BIGCOLOR.PRG V1.05
  2. ;                    JON DALTON    
  3. ;                    DECEMBER 1989
  4.  
  5.  MOVE.W #4,-(SP)
  6.  TRAP #14                 ; Check MONO monitor attached
  7.  ADDQ.L #2,SP
  8.  CMP.W #2,D0              ; If not, then end program (NODO)
  9.  BEQ HIGH
  10. NODO:        
  11.  MOVE.L #MONO1,-(SP)      ; Address of end message
  12.  MOVE.W #9,-(SP)          ; Print message
  13.  TRAP #1
  14.  ADDQ.L #6,SP
  15.  MOVE.W #0,-(SP)          ; End program and return to GEM desktop
  16.  TRAP #1                      
  17. HIGH:
  18.  CLR.L -(SP)              ; Go into Supervisor mode
  19.  MOVE.W #32,-(SP)
  20.  TRAP #1                      
  21.  ADDQ.L #6,SP
  22.  MOVE.L D0,SUPERVISOR      ; Save the old stack pointer
  23.                                                         
  24. ;The next 16 lines check whether the program has already been run by
  25. ;checking memory location $3EC for 'magic number' $ABCCBA12.  If
  26. ;it has been run, memory location $3F0 should contain start address
  27. ;of the program in high memory.  If not, it reserves memory by changing
  28. ;$42E (PHYSTOP) and rebooting.
  29.  CMP.L #$abccba12,$3Ec
  30.  BNE DUMPIT
  31.  MOVE.L $42E,D0
  32.  CMP.L $3F0,D0
  33.  BLE ITSOK
  34.  MOVE.L $3F0,$42E
  35.  RESET
  36. DUMPIT:
  37.  MOVE.L $42E,A0
  38.  CMP.L #$abccba12,(A0)
  39.  BEQ ITSOK
  40. RESSET:
  41.  MOVE.L #$abccba12,$3Ec
  42.  SUB.L #$32000,$42E
  43.  MOVE.L $42E,$436
  44.  MOVE.L $42E,$3F0
  45.  RESET
  46.  
  47. ITSOK:
  48.  MOVE.L #$ABCCBA12,$3EC
  49.  MOVE.L #STARTUP,-(SP)      ; Print STARTUP
  50.  MOVE.W #9,-(SP)               
  51.  TRAP #1
  52.  ADDQ.L #6,SP
  53.  
  54. ;Input the screen refresh rate
  55. INPUTT:
  56.  MOVE.L #INPUT,-(SP)
  57.  MOVE.W #9,-(SP)              ; Print message
  58.  TRAP #1
  59.  ADDQ.L #6,SP
  60.  MOVE.B #1,STORE             
  61.  MOVE.L #STORE,-(SP)
  62.  MOVE.W #10,-(SP)             ; Input the digit  
  63.  TRAP #1                      
  64.  ADDQ.L #6,SP
  65.  TST.B STORE+1
  66.  BNE INPUTOK             ; If return has been pressed, SPEED is set to 14
  67.  MOVE.L #AVERAGE,-(SP)
  68.  MOVE.W #9,-(SP)              ; Print AVERAGE
  69.  TRAP #1
  70.  ADDQ.L #6,SP
  71.  MOVE.W #14,D0
  72.  BRA DEFAULT
  73. INPUTOK:
  74.  MOVE.B STORE+2,D0         
  75.  SUB.W #47,D0
  76.  BLE INPUTT          ; Not a number or letter
  77.  CMP.W #10,D0
  78.  BGT NODO            ; A letter has been entered, so exit the program
  79.  SUB.W #1,D0
  80.  MULU #4,D0          ; Multiply by 4 to get SPEED
  81.  TST D0
  82.  BNE DEFAULT
  83.  MOVE.W #50,D0       ; Zero entered, so set SPEED equal to 50
  84. DEFAULT:
  85.  MOVE.W D0,SPEED
  86.  
  87. ;The next 24 lines check whether the program is already installed in
  88. ;high memory, and activates it by setting up VBLANK, XBIOS  MONITOR-
  89. ;CHANGED and ETVTERM VECTORS, the addresses of which are at the start of
  90. ;the program which is found from $3F0.  It also sets up the new SPEED,
  91. ;and sets GEM desktop to colour.
  92.  MOVE.L $3F0.W,D0
  93.  MOVE.L D0,A0        ; Checks the program has been installed before
  94.  MOVE.L (A0),D0
  95.  CMP.L #$ABCCBA12,D0 ; 'Magic Number'
  96.  BNE INSTALL
  97.  MOVE.W SR,-(SP)
  98.  OR.W #$0700,SR       ; Set interupt level to 7
  99.  ADDQ.L #4,A0
  100.  MOVE.L (A0)+,$0B8.W  ; Sets up the new vectors
  101.  MOVE.L (A0)+,$070.W
  102.  MOVE.L (A0)+,$46E.W
  103.  MOVE.L (A0)+,$408.W
  104.  MOVE.L (A0)+,A0
  105.  MOVE.L SPEED,(A0)     ; Set SPEED that has been entered
  106.  ADD.L #28,A0
  107.  MOVE.B #3,(A0)
  108.  MOVE.W (SP)+,SR
  109.  MOVE.W #37,-(SP)
  110.  TRAP #14
  111.  ADDQ.L #2,SP
  112.  MOVE.W #0,-(SP)
  113.  MOVE.L #-1,-(SP)
  114.  MOVE.L #-1,-(SP)
  115.  MOVE.W #5,-(SP)     ; Set GEM DESKTOP to colour
  116.  TRAP #14
  117.  ADD.L #12,SP
  118.  BRA ENDPROG
  119.  
  120. ;Program has not been installed before. 
  121. INSTALL:
  122.  MOVE.L #CALCULATE,-(SP)
  123.  MOVE.W #9,-(SP)           ; Print message that it is installing.
  124.  TRAP #1
  125.  ADD.L #6,SP
  126.  
  127. ;TABLE CALCULATION.  The next 42 lines calculates a lookup table
  128. ;that converts a binary word %aaaaaaaabbbbbbbb into a binary word
  129. ;%babababababababa. It does this transformation on all possible
  130. ;words, starting at $0000 then $0001 etc up to $FFFE.  $FFFF is added 
  131. ;at the end.  It is slow as it has to check every bit of every word.
  132.  MOVE.L #CODE,D0   ; Place the lookup table at this address
  133.  MOVE.L D0,TABLE   ; $20000 bytes long
  134.  CLR.L D4                     
  135.  MOVE.W #0,D4
  136.  MOVE.L D0,A4            
  137.  CLR.L D0                
  138.  CLR.L D2
  139. WORDLOOP:
  140.  CLR.L D6
  141.  CLR.L D5
  142.  CLR.L D3
  143.  MOVE #7,D5       ; Loop round 8 times for one byte (the low byte)
  144.  MOVE #1,D3       ; D3 is a mask which moves up the byte
  145.  MOVE.L D3,D1     ; D1 contains the position of the mask temporarily
  146.  MOVE.L D4,D0     ; D4 contains the word which is being transformed
  147. BITLOOP:
  148.  AND.L D0,D1      ; D0 contains the word temporarily
  149.  MULU D1,D1       ; Move the bit to its new location, if it was set
  150.  ADD.L D1,D2      ; D2 has the transformed set bits added to it
  151.  ADD D3,D3        ; Shift the mask left one bit 
  152.  MOVE.L D3,D1
  153.  DBF D5,BITLOOP   ; Loop round 8 times
  154.  TST.L D6         ; D6 is set when the high byte has been dealt with
  155.  BNE MOREDO1:
  156.  LSR.L #8,D0      ; Move the high byte to the low byte
  157.  LSL.L #1,D2      ; Offset the bits that have already been calculated
  158.  CLR.L D3
  159.  CLR.L D1
  160.  MOVE #1,D3       ; Reset the mask (D3) to #1 
  161.  MOVE D3,D1
  162.  MOVE.L #1,D6     ; Set D6 to indicate high byte is being dealt with
  163.  MOVE.L #7,D5
  164.  BRA BITLOOP      ; Repeat the process (high byte is now low byte) 
  165. MOREDO1:
  166.  CLR.L D6         ; Clear D6 ready to start a new word 
  167.  MOVE.W D2,(A4)+  ; Save the completed transformed word in the table
  168.  CLR.L D2
  169.  ADDQ #1,D4       ; Add #1 to get the next word to transform
  170.  CMP #$FFFF,D4    ; Check whether all the words have been done
  171.  BEQ FINISH
  172.  BRA WORDLOOP     ; Loop back to calculate the next word
  173. FINISH:
  174.  MOVE.W #$FFFF,(A4)+  ; The last entry in the table
  175.  
  176. ;Set up the extra screen needed for monochrome, and the check screen.
  177. ;Place the screens after the table, making sure they lie on a 256-byte
  178. ;boundary.
  179.  MOVE.L A4,D0        ; A4 is the address after the table
  180.  ADD.L #$100,D0                  
  181.  AND.L #$FFFFFF00,D0 ; Make sure that last byte is zero (for screen)      
  182.  MOVE.L D0,MONO      ; Set MONO screen (which is actually displayed)
  183.  ADD.L #$8000,D0     ; COLOURCHECK screen to detect changes in COL screen
  184.  MOVE.L D0,COLOURCHECK
  185.  
  186. ;Work out OFFSET for where the program is to be moved to in high memory
  187.  MOVE.L $3F0,D1
  188.  SUB.L #MONITOR,D1
  189.  ADD.L #512,D1
  190.  AND.L #$FFFFFE00,D1
  191.  MOVE.L D1,OFFSET
  192.  ADD.L D1,MONO
  193.  ADD.L D1,TABLE
  194.  ADD.L D1,COLOURCHECK
  195.  
  196. ;Clear the new screens
  197.  MOVE.L COLOURCHECK,A4
  198.  MOVE.L MONO,A5
  199.  CLR.L D1
  200.  CLR.L D0
  201.  MOVE.W #7999,D1
  202. LOADIT:
  203.  MOVE.L D0,(A4)+     ; Loads the table with zero to start
  204.  MOVE.L D0,(A5)+
  205.  DBF D1,LOADIT
  206.  MOVE.L $44E.W,COL   ; Set up COL address (colour screen)
  207.  
  208. ;Move the actual display to MONO address and set up SCRNCHK (to detect if
  209. ;the displayed screen address has been changed)
  210.  MOVE.L MONO,D0
  211.  LSR.L #8,D0
  212.  MOVE.L #$FF8200,A5
  213.  MOVEP.W D0,1(A5)
  214.  MOVE.L (A5),SCRNCHK
  215.  CLR.L D0
  216.  
  217. ;Put the VECTOR addresses in the new code (replacing DUMMY) and set
  218. ;up the other variables.
  219.  MOVE.L $B8.W,VECTOR1+2     
  220.  MOVE.L $70.W,VECTOR2+2     
  221.  MOVE.L $70.W,VECTOR2A+2
  222.  MOVE.L $408.W,VECTOR3+2
  223.  MOVE.L $70.W,VBLADD
  224.  MOVE.L #0,POSITION         ; Set the position to the top
  225.  MOVE.L #199,COUNTER        ; Set counter to count down from 200 (DBF loop)
  226.  MOVE.B #0,COLOR            ; Set COLOR to #0 (Low Resolution)
  227.  MOVE.L #VBLANK,NEWVBL
  228.  
  229. ;Set up the new MONITOR CHANGED vector and set up GEM DESKTOP to colour
  230.  MOVE.L #MONITOR,$46E 
  231.  MOVE.W #0,-(SP)
  232.  MOVE.L #-1,-(SP)
  233.  MOVE.L #-1,-(SP)
  234.  MOVE.W #5,-(SP)
  235.  TRAP #14
  236.  ADD.L #12,SP
  237.  
  238. ;Move the program to high memory.  Offset has already been calculated,
  239. ;various addresses need to be relocated so they have D6 added to them.
  240.  MOVE.L #MONITOR,A3       ; MONITOR is the start address to relocate
  241.  MOVE.L A3,A4
  242.  ADD.L OFFSET,A4
  243.  MOVE.L OFFSET,D6
  244.  ADD.L D6,REL1+2          ; Add the offset to variables
  245.  ADD.L D6,REL2+2
  246.  ADD.L D6,REL3+2
  247.  ADD.L D6,REL4+2
  248.  ADD.L D6,REL5+2
  249.  ADD.L D6,REL6+2
  250.  ADD.L D6,REL7+2
  251.  ADD.L D6,REL8+2
  252.  ADD.L D6,REL9+2
  253.  ADD.L D6,REL10+2
  254.  ADD.L D6,REL11+2
  255.  ADD.L D6,REL12+2
  256.  ADD.L D6,REL14+2
  257.  ADD.L D6,REL15+2
  258.  ADD.L D6,REL16+2
  259.  ADD.L D6,REL17+6
  260.  ADD.L D6,REL18+6
  261.  ADD.L D6,REL20+2
  262.  ADD.L D6,REL21+2
  263.  ADD.L D6,REL22+2
  264.  ADD.L D6,REL34+2
  265.  ADD.L D6,REL35+2
  266.  ADD.L D6,REL40+2
  267.  ADD.L D6,REL41+2
  268.  ADD.L D6,REL73+2
  269.  ADD.L D6,REL74